package toolfunc

import "strings"

// 将KB、MB、GB和TB转换为字节的
const (
	_        = iota
	KB int64 = 1 << (10 * iota)
	MB
	GB
	TB
)

// size是数值，uint是单位
func ToBytes(size int64, unit string) int64 {
	switch strings.ToLower(unit) {
	case "kb":
		return size * KB
	case "mb":
		return size * MB
	case "gb":
		return size * GB
	case "tb":
		return size * TB
	default:
		return size
	}
}
